package com.navi.loaddata.loadService.impl.hisData;

import com.navi.loaddata.core.mesEntity.MesProducthistory;
import com.navi.loaddata.core.mysqlEntity.EtlConfDModel;
import com.navi.loaddata.core.oracleEntity.EtlGlassHstV;
import com.navi.loaddata.core.repository.impl.MesRepositoryImpl;
import com.navi.loaddata.loadService.impl.hisData.array.ProcessHisDataServiceARRAY2;
import com.navi.loaddata.loadService.impl.hisData.cell1.ProcessHisDataServiceCELL12;
import com.navi.loaddata.loadService.impl.hisData.cell2.ProcessHisDataServiceCELL22;
import com.navi.loaddata.loadService.impl.hisData.cf.ProcessHisDataServiceCF2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author jay
 */
@Service
public class ProcessHisDataService {
    @Autowired
    private MesRepositoryImpl mesdao;
    @Autowired
    private ProcessHisDataServiceARRAY2 processHisDataServiceARRAY;
    @Autowired
    private ProcessHisDataServiceCF2 processHisDataServiceCF;
    @Autowired
    private ProcessHisDataServiceCELL12 processHisDataServiceCELL1;
    @Autowired
    private ProcessHisDataServiceCELL22 processHisDataServiceCELL2;

    private static final Logger logger = LoggerFactory.getLogger(ProcessHisDataService.class);

    public EtlGlassHstV processHis(EtlConfDModel etlConfD, MesProducthistory his, Map<String, MesProducthistory> hisTrackIn) throws Exception {

        EtlGlassHstV etlGlassHstV = new EtlGlassHstV();
        switch (etlConfD.getShop()) {
            //直接赋值，外面转化
            case "ARRAY":
                etlGlassHstV = processHisDataServiceARRAY.processHis(hisTrackIn, his);
                break;
            case "CF":
                etlGlassHstV = processHisDataServiceCF.processHis(hisTrackIn, his);
                break;
            case "OC":
                if ("CELL1".equals(etlConfD.getCellType())) {
                    etlGlassHstV = processHisDataServiceCELL1.processHis(hisTrackIn, his);
                } else if ("CELL2".equals(etlConfD.getCellType())) {
                    etlGlassHstV = processHisDataServiceCELL2.processHis(hisTrackIn, his);
                }
                break;
        }
        return etlGlassHstV;
    }
}
